# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Contributor: Dario Ostuni <dario.ostuni@gmail.com>

pkgname=binaryen
epoch=1
pkgver=112
pkgrel=1
pkgdesc="Compiler infrastructure and toolchain library for WebAssembly, in C++"
arch=('loong64' 'x86_64')
url="https://github.com/WebAssembly/binaryen"
license=('MIT')
makedepends=('cmake' 'ninja' 'python')
options=('!lto')
source=("$pkgname-$pkgver.tar.gz::https://github.com/WebAssembly/binaryen/archive/version_${pkgver}.tar.gz"
        "binaryen.sh")
sha384sums=('26d9e48a12d46833a3fa22b51e62c3d3f2bf4ff8cde69a28f09d257eab2a4378ecd946e802394395081b19272551d31e'
            '8ccff587d33aa2f8e66cc167ab887087993cea0899921d2e7cc69372c8b659770a4f4a00e9da61c75394af002c8c7660')

build() {
    cd binaryen-version_$pkgver

    cmake \
        -Bbuild \
        -GNinja \
        -DBUILD_TESTS=OFF \
        -DCMAKE_INSTALL_PREFIX=/usr
    ninja -C build
}

package() {
    cd binaryen-version_$pkgver
    DESTDIR="$pkgdir" ninja -C build install

    install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    install -Dm755 "$srcdir"/binaryen.sh "$pkgdir"/etc/profile.d/binaryen.sh
}
